*****************************************************************************************************
* Replication file for Urdinez et.al.(2016)
* Chinese Economic Statecraft and U.S. Hegemony in Latin America: An Empirical Analysis, 2003�2014
*@ Latin American Politics and Society 
*****************************************************************************************************
set more off 
xtset ccode year

*American Influence Index:
corr unga_imp milaid_pc ecoaid_pc ofdi xxtot 
egen unga_impstd=std(unga_imp)
egen ecoaidstd= std(ecoaid_pc)
egen milaidstd= std(milaid_pc)
egen ofdistd= std(ofdi)
egen xxtotstd= std(xxtot)
pca unga_impstd ecoaidstd milaidstd ofdistd xxtotstd, mineig(1)
screeplot, yline(1)
predict pc1 pc2 pc3, score
estat kmo
gen INDEX= pc1*(25/69)+pc2*(22/69)+pc3*(20/69)
egen min_INDEX =min(INDEX)
egen max_INDEX =max(INDEX)
gen normal_INDEX=(INDEX-min_INDEX)/(max_INDEX-min_INDEX)
rename normal_INDEX index
 
*TABLE 3: Regression models are run separately. 
xtset ccode year

**3.1 FDI SOES:
xtpcse soes_pc l.soes_pc  c.index i.taiwan commodity_cicle strategic_partnership_dummy education tariff_manuf bit_china gas_rents_gdp oil_rent_gdp land_pc mineral_rents_gdp gdp gdppc imports_pc  legal property corru opefdi invfree , c(p)
estimates store soes

**FIGURE 2:
xtset ccode year
by ccode: replace soes_pc_lag1 = soes_pc[_n-1]
xtpcse soes_pc soes_pc_lag1  c.index i.taiwan commodity_cicle strategic_partnership_dummy education bit_china gas_rents_gdp   oil_rent_gdp  land_pc mineral_rents_gdp gdp gdppc imports_pc    legal property corru opefdi invfree, c(p)
margins , at(index=(0(.1)1))
marginsplot, scheme(sj)

**3.2 FDI POES:
xtpcse poes_pc l.poes_pc  c.index i.taiwan commodity_cicle strategic_partnership_dummy tariff_manuf education bit_china gas_rents_gdp oil_rent_gdp  land_pc mineral_rents_gdp gdp gdppc imports_pc  legal property corru opefdi invfree , c(p)
estimates store poes

**FIGURE 2:
by ccode: replace poes_pc_lag1 = poes_pc[_n-1]
xtpcse poes_pc poes_pc_lag1 c.index i.taiwan commodity_cicle strategic_partnership_dummy  tariff_manuf education bit_china gas_rents_gdp   oil_rent_gdp  land_pc mineral_rents_gdp gdp gdppc imports_pc  legal property corru opefdi invfree, c(p)
margins , at(index=(0(.1)1))
marginsplot, scheme(sj)

**3.3 CHINA LOANS:
xtpcse loans_pc l.loans_pc  c.index i.taiwan commodity_cicle strategic_partnership_dummy m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, c(p)
estimates store chiloans

**FIGURE 3:
by ccode: replace loans_pc_lag1 = loans_pc[_n-1]
xtpcse loans_pc loans_pc_lag1  c.index i.taiwan commodity_cicle strategic_partnership_dummy m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, c(p)
margins , at(index=(0(.1)1))
marginsplot, scheme(sj)

**3.4 IBRD LOANS:
xtpcse d.ibrd_pc d.l.ibrd_pc  c.index i.taiwan commodity_cicle strategic_partnership_dummy m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, c(p)
estimates store westloans

**3.5 EXPORTS:
xtpcse exports_pc l2.exports_pc c.index i.taiwan commodity_cicle strategic_partnership_dummy fta_china taxes_on_products_pc terms_trade_pc tariff_manuf gdppc   inflation exchrate tradefree employ_ind trade_open , c(p)
estimates store expo

*FIGURE 4:
by ccode: replace exports_pc_lag1 = exports_pc[_n-2]
xtpcse exports_pc exports_pc_lag1 c.index i.taiwan commodity_cicle strategic_partnership_dummy fta_china taxes_on_products_pc terms_trade_pc tariff_manuf  gdppc   inflation exchrate tradefree employ_ind trade_open , c(p)
margins , at(index=(0(.1)1))
marginsplot, scheme(sj)

**3.6 IMPORTS:
xtpcse imports_pc l2.imports_pc gdppc c.index i.taiwan commodity_cicle strategic_partnership_dummy  land_pc gas_rents_gdp mineral_rents_gdp oil_rent_gdp fta_china terms_trade_pc trade_open employ_ind exchrate tradefree, c(p)
estimates store impo

*The following line creates TABLE 3 as in the paper:
esttab soes poes chiloans westloans expo impo, r2 ar2 se


* APPENDIX:

*TABLE A:
sort country
by country: tabstat index unga_imp ecoaid_pc milaid_pc ofdi xxtot, s(sd me min max)

*CORRELATION MATRIX:
pwcorr index taiwan land_pc gdp imports_pc education inflation exchrate property corru opefdi invfree finfree tradefree legal m2_gdp interest_rate_spread taxes_on_products_pc terms_trade_pc tariff_manuf debtservice external_debt_stock_gni bit_china fta_china gas_rents_gdp mineral_rents_gdp energy_gdp oil_rent_gdp oil_prod trade_open commodity_cicle strategic_partnership_dummy

*ROBUSTNESS CHECK. NOT IN THE PAPER:

* COMPONENTS OF THE INDEX AS INDEPENDENT VARIABLES 
xtset ccode year
** D.1. FDI SOES
xtpcse soes_pc l.soes_pc  unga_imp milaid_pc ecoaid_pc ofdi xxtot  taiwan commodity_cicle strategic_partnership_dummy education bit_china gas_rents_gdp   oil_rent_gdp oil_prod land_pc mineral_rents_gdp gdp gdppc  inflation legal property corru invfree, c(p)
estimates store soes2
** D.2. FDI POES
xtpcse poes_pc l.poes_pc unga_imp milaid_pc ecoaid_pc ofdi xxtot  taiwan commodity_cicle strategic_partnership_dummy education bit_china gas_rents_gdp   oil_rent_gdp oil_prod land_pc mineral_rents_gdp gdp gdppc imports_pc   inflation legal property corru opefdi invfree, c(p)
estimates store poes2
** D.3. Loans from Chinese banks
xtpcse loans_pc l.loans_pc  unga_imp milaid_pc ecoaid_pc ofdi xxtot  taiwan commodity_cicle strategic_partnership_dummy m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, c(p)
estimates store chiloans2
** D.4.Loans from bird como contrafactual
xtpcse ibrd_pc l.ibrd_pc  unga_imp milaid_pc ecoaid_pc ofdi xxtot taiwan commodity_cicle strategic_partnership_dummy m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, c(p)
estimates store westloans2
** D.5.Chinese exports of manufactures
xtpcse exports_pc l.exports_pc unga_imp milaid_pc ecoaid_pc ofdi xxtot commodity_cicle strategic_partnership_dummy  taiwan dist_china fta_china taxes_on_products_pc terms_trade_pc 
 gdp gdppc   inflation exchrate tradefree employ_ind trade_open , c(p)
estimates store expo2
** D.6.Chinese imports of commodities
xtpcse imports_pc l.imports_pc  unga_imp milaid_pc ecoaid_pc ofdi xxtot commodity_cicle strategic_partnership_dummy taiwan  land_pc gas_rents_gdp oil_prod dist_china fta_china terms_trade_pc trade_open employ_ind  , c(p)
estimates store impo2
** Compile all models in one table:
esttab soes2 poes2 chiloans2 westloans2 expo2 impo2, r2 ar2 se

**GMM
xtabond2 soes_pc l.soes_pc  c.index i.taiwan commodity_cicle strategic_partnership_dummy education tariff_manuf bit_china gas_rents_gdp oil_rent_gdp land_pc mineral_rents_gdp gdp gdppc imports_pc  legal property corru opefdi invfree , gmm(c.index i.taiwan education tariff_manuf bit_china gas_rents_gdp oil_rent_gdp land_pc mineral_rents_gdp gdp gdppc imports_pc  legal property corru opefdi invfree, eq(l)) h(2) comp(2)
xtabond2 poes_pc poes_pc_lag1 c.index i.taiwan commodity_cicle strategic_partnership_dummy  tariff_manuf education bit_china gas_rents_gdp   oil_rent_gdp  land_pc mineral_rents_gdp gdp gdppc imports_pc  legal property corru opefdi invfree, gmm(c.index i.taiwan  tariff_manuf education bit_china gas_rents_gdp   oil_rent_gdp  land_pc mineral_rents_gdp gdp gdppc imports_pc  legal property corru opefdi invfree, eq(l)) h(2) comp(2)
xtabond2 loans_pc loans_pc_lag1  c.index i.taiwan commodity_cicle strategic_partnership_dummy m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, gmm(c.index i.taiwan m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, eq(l)) h(1) comp(2)
xtabond2 ibrd_pc l.ibrd_pc  c.index i.taiwan commodity_cicle strategic_partnership_dummy m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, gmm(c.index i.taiwan m2_gdp interest_rate_spread debtservice external_debt_stock_gni  oil_rent_gdp oil_prod gas_rents_gdp land_pc mineral_rents_gdp gdp gdppc   inflation finfree, eq(l)) h(1) comp(1)



